import string
#用户输入，判断合法性
def main():
    s = input("请输入一串字符串(0,255]：\n")
    if len(s)<=0 or len(s)>255:
        print("输入的字符数量不在（0,255]之间")
        s = input("请重新输入一串字符串：\n")
    letter(s)

#letter，剔除字符串中的非英文字符
def letter(s):
    #print(' '.join(filter(str.isalpha,s)))
    newS=''
    for i in s:
        uni=ord(i)
        if(97<=uni<=122) or (65<=uni<=90):
            newS=newS+i
    reverse(newS)

#reverse，将接收到的全英文字符全部反转
def reverse(a):
    l = list(a)
    l.reverse()
    enCode(a)

#enCode，加密后输出
def enCode(s):
    newS=''
    for c in s:
        if 'a'<=c<='z':
            newS += chr(ord('a') + ((ord(c) - ord('a'))+3)%26)
        elif 'A'<=c<='Z':
            newS += chr(ord('A') + ((ord(c) - ord('A')) + 3) % 26)
    print(s)
    print(newS)
main()



